public class Solution551 {
    public boolean checkRecord(String s) {
        char[] chars=s.toCharArray();
        int count=0;
        for (int i=0;i<chars.length;i++){
            if (chars[i]=='A'){
                count++;
            }else if (chars[i]=='L'){
                if (i+2<chars.length&&chars[i+1]=='L'&&chars[i+2]=='L'){
                    return false;
                }
            }
        }
        if (count<2) return true;
        return false;
    }

    public static void main(String[] args) {
        System.out.println(new Solution551().checkRecord("PPALLP"));
    }
}
